vcActionContainer

vcActionContainer is a container of vcAction objects used for storing, buffering, sending and receiving actions between resource clients, providers and brokers. Each vcActionContainer may fulfill multiple roles: - Providers are resources which perform actions. - Clients request Providers to perform actions. - Brokers connect Clients to Providers indirectly by routing action requests. How the actions are defined, handled, executed, and their properties interpreted are completely up to the Python scripts in each simulation. The implementation for methods in this class related to resource use, reservation, and work delegation can be overridden by registering corresponding callbacks.

See in: Overview

Module: vcBehaviors

Parent: vcBehavior

Children -

Referenced by: vcAction.ActionContainer, vcAction.From, vcAction.Receiver, vcAction.Sender, ... (see more)
vcAction.ActionContainer
vcAction.From
vcAction.Receiver
vcAction.Sender
vcAction.To
vcSimActionField.Actions

Properties

Learn how to use properties here. The properties are also inherited from the parent class.

NameTypeAccessDescription
ActionsvcList[vcAction]RGets a list of actions in container.
BrokersvcList[vcActionContainer]RWGets or sets the connected vcActionContainers that are considered to fulfill the "Broker" role by this container.
ClientsvcList[vcActionContainer]RWGets or sets the connected vcActionContainers that are considered to fulfill the "Client" role by this container.
ConnectionsvcListRWGets or sets list of Python script behaviors within component that will process received actions.
See more
The scripts should have a OnAction(action: vcAction) method, which gets called when an action is to be processed by this container.
NextFreeTimeRealRWGets or sets the next available time this container is expected to be able to process actions. Expressed in simulation seconds.
OnResourceDoobjectRWGets or sets a callback function to override default behavior.
OnResourceReleaseobjectRWGets or sets a callback function to override default behavior.
OnResourceReserveobjectRWGets or sets a callback function to override default behavior.
OnResourceStartobjectRWGets or sets a callback function to override default behavior.
OnResourceUseobjectRWGets or sets a callback function to override default behavior.
OnResourceWaitobjectRWGets or sets a callback function to override default behavior.
PendingActionCountIntegerRGets the number of pending actions. This is equivalent to len(PendingActions) but faster to execute.
PendingActionsvcList[vcAction]RGets a list of pending action stored in the container.
See more
That is, actions that are received from other action containers and buffered for action processing.
ProcessingBooleanRWGets or sets a value indicating whether this container is executing actions.
ProvidersvcList[vcActionContainer]RWGets or sets the connected vcActionContainers that are considered to fulfill the "Provider" role by this container.
ReservedForvcActionContainerRWGets or sets the vcActionContainer this container is reserved for. The value can be the container itself.

Methods

Learn how to use methods here. The methods are also inherited from the parent class.

NameReturn TypeParametersDescription
clearNoneNoneDeletes all vcActionContainer.Actions in this container.
clearPendingNoneNoneDeletes all vcActionContainer.PendingActions in this container.
createActionvcActionString actionNameCreates a new action to the Actions list and returns it.
See more
Parameters:
actionName (str): Value to assign as vcAction.Name.

Returns:
vcAction: The created action.
createPendingActionvcActionString actionNameCreates a new action to the PendingActions list and returns it.
See more
Parameters:
actionName (str): Value to assign as vcAction.Name.

Returns:
vcAction: The created action.
doobjectString actionType,
Optional Keyword[timeout = Real],
Optional Keyword[requestTemplate = vcAction],
Optional Keyword[requestCustomizer = Callable]
Executes an action using this vcActionContainer and waits for its completion.

Constructs and registers a request vcAction, and then calls either the OnResourceDo callback if it is defined, or the default implementation in vcHelpers.ResourceTools.
See more
This function returns an awaitable task. It must be awaited.

Parameters:
actionType (str): Value to assign as request vcAction.Name.
Optional: timeout (float): Maximum amount of simulation time to wait for the action execution to start.
Optional: requestTemplate (vcAction): Action to copy as template for the request.
Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent.

Returns:
Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether the action was performed within the timeout limit.

Exceptions:
ValueError: When requestCustomizer has incorrect function signature.
RuntimeError: When this vcActionContainer hasn't been reserved.
moveActionNonevcAction action,
Integer index
Moves a given action to a new position in the Actions property list.
See more
Parameters:
action (vcAction): The action object to move.
index (int): 0-based desired position in the Actions list.

Exceptions:
IndexError: When the index is out of bounds of the Actions list.
RuntimeError: When the action is not in the Actions list.
movePendingActionNonevcAction action,
Integer index
Moves a given action to a new position in the PendingActions property list.
See more
Parameters:
action (vcAction): The action object to move.
index (int): 0-based desired position in the PendingActions list.

Exceptions:
IndexError: When the index is out of bounds of the PendingActions list.
RuntimeError: When the action is scheduled for deletion.
RuntimeError: When the action is not in the PendingActions list.
popPendingvcActionNoneRemoves the last action from the PendingActions list and returns that action.

Returns:
vcAction: The removed action or None if there are no pending actions.
popPendingvcActionInteger indexRemoves N:th from last action from the PendingActions list, and then returns that action.
See more
Parameters:
index (int): 0-based index counted from the end of PendingActions list.

Returns:
vcAction: The removed action.

Exceptions:
IndexError: When the index is out of bounds.
releaseBooleanNoneReleases the reservation of this container from the vcActionContainer defined in the ReservedFor property.
See more
Notifies the vcActionContainer this resource was reserved by.

Calls either the OnResourceRelease callback if it is defined, or the default implementation in vcHelpers.ResourceTools.

Returns:
bool: A value indicating whether the release was successful.
removePendingActionBooleanvcAction actionTries to remove a given action from the PendingActions list and any other action containers it has been broadcast to.
See more
Removed actions are not deleted automatically, and failing to do so will result in a memory leak.

Parameters:
action (vcAction): The action object to remove.

Returns:
bool: True when action was found and removed, False otherwise.

Exceptions:
RuntimeError: When the action object has been scheduled for deletion.
reserveobjectString resourceFilter,
Optional Keyword[actionType = String],
Optional Keyword[timeout = Real],
Optional Keyword[requestTemplate = vcAction],
Optional Keyword[requestCustomizer = Callable]
Finds a connected vcActionContainer available to execute a specific action and reserves it.
Waits for a resource to become available if necessary.

Constructs and registers a request vcAction, and then calls either the OnResourceReserve callback if it is defined, or the default implementation in vcHelpers.ResourceTools.
See more
This function returns an awaitable task. It must be awaited.

Parameters:
resourceFilter (str): Substring that needs to appear in vcComponent.Name of the component that owns the resource vcActionContainer.
Optional: actionType (str): Value to assign as request vcAction.Name.
Optional: timeout (float): Maximum amount of simulation time to wait for a resource to become available.
Optional: requestTemplate (vcAction): Action to copy as template for the request.
Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent.

Returns:
Awaitable[vcActionContainer | None]: The task instance. When awaited, returns the reserved vcActionContainer or None if no resource was available within the timeout.

Exceptions:
ValueError: When requestCustomizer has incorrect function signature.
startvcActionString actionType,
Optional Keyword[requestTemplate = vcAction],
Optional Keyword[requestCustomizer = Callable]
Starts execution of an action in this container regardless if another action is still running.
Generally, start() is used with the wait() method in order to catch when an action executed with start() has been completed.
See more
Constructs and registers a request vcAction, and then calls either the OnResourceStart callback if it is defined, or the default implementation in vcHelpers.ResourceTools.

Parameters:
actionType (str): Value to assign as request vcAction.Name.
Optional: requestTemplate (vcAction): Action to copy as template for the request.
Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent.

Returns:
vcAction: The created request action.

Exceptions:
ValueError: When requestCustomizer has incorrect function signature.
useobjectString resourceFilter,
String actionType,
Optional Keyword[timeout = Real],
Optional Keyword[requestTemplate = vcAction],
Optional Keyword[requestCustomizer = Callable]
Finds a connected vcActionContainer available to execute a specific action and waits for its completion.
Waits for a resource to become available if necessary.

Constructs and registers a request vcAction, and then calls either the OnResourceUse callback if it is defined, or the default implementation in vcHelpers.ResourceTools.
See more
This function returns an awaitable task. It must be awaited.

Parameters:
resourceFilter (str): Substring that needs to appear in vcComponent.Name of the component that owns the resource vcActionContainer.
actionType (str): Value to assign as request vcAction.Name.
Optional: timeout (float): Maximum amount of simulation time to wait for a resource to become available.
Optional: requestTemplate (vcAction): Action to copy as template for the request.
Optional: requestCustomizer (Callable[vcAction]): Callback that allows to edit the created request vcAction before it is sent.

Returns:
Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether a resource was found and reserved within the timeout limit.

Exceptions:
ValueError: When requestCustomizer has incorrect function signature.
waitobjectOptional Keyword[timeout = Real]Waits until action called in start() method is completed.
See more
This function returns an awaitable task. It must be awaited.

Parameters:
Optional: timeout (float): Maximum simulation time in seconds to wait for action completion.

Returns:
Awaitable[bool]: Task representing the operation. When awaited, returns a value indicating whether the action was completed within the timeout limit.